package com.jpcc.vw.onlineRadio.utils;

import java.util.concurrent.TimeUnit;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * 线程切换工具
 * 以及500毫秒的防抖
 * Created by liukanshan on 2016/12/9.
 */
public class TransformUtils {

    public static <T> Observable.Transformer<T, T> defaultSchedulers() {
        return new Observable.Transformer<T, T>() {
            @Override
            public Observable<T> call(Observable<T> tObservable) {
                return tObservable.observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).throttleFirst(500, TimeUnit.MILLISECONDS);
            }
        };
    }
}
